// /////////////////////////////////////////////////////////////////////////////
//
// Name:            asSerializedAttribute.cpp
// Author:          Michael Bartsch (ZCCdark203)
//
// Desc :           Binds the SerializedAttribute class to AngelScript
//
// License:         Copyright (C) 2009 Michael Bartsch and Contributors
//
//                  This program is free software: you can redistribute it
//                  and/or modify it under the terms of the zlib/libpng License.
//                  See main.cpp for conditions of distribution and use.
//
// /////////////////////////////////////////////////////////////////////////////

// Include files
#include "asSerializedAttribute.h"

#ifdef __COMPILE_WITH_ANGELSCRIPT__

#include "asSerializable.h"
#include "../ScriptHelper.h"

#include "../../core/SerializedAttribute.h"


//! Wrapper function to allow classes "derived" from the Serializable class to be
//! used by the SerializedAttribute::setObject.
void setObject(asIScriptObject *object, SerializedAttribute *pAttribute)
{
    ScriptedSerializable *serializable = new ScriptedSerializable(object);
    pAttribute->setObject(serializable);
    serializable->drop();
}


//! Binds the SerializedAttribute class to AngelScript.
void bindSerializedAttribute(asIScriptEngine *engine)
{
    // Forward declarations.
    int r;

    // Bind SerializedAttribute class.
    r = engine->RegisterObjectType("SerializedAttribute", sizeof(SerializedAttribute), asOBJ_REF);

    // Set SerializedAttribute behaviour.
    r = engine->RegisterObjectBehaviour("SerializedAttribute", asBEHAVE_ADDREF, "void f()",
                                        asMETHOD(SerializedAttribute, grab), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectBehaviour("SerializedAttribute", asBEHAVE_RELEASE, "void f()",
                                        asMETHOD(SerializedAttribute, drop), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("SerializedAttribute", "SerializedAttribute& opAssign(const SerializedAttribute &in)",
                                        asFUNCTION(assignT<SerializedAttribute>), asCALL_CDECL_OBJLAST); assert(r >= 0);

    // Bind SerializedAttribute class functions.
    r = engine->RegisterObjectMethod("SerializedAttribute", "const string& getName()",
                                     asMETHOD(SerializedAttribute, getName), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "const string& getType()",
                                     asMETHOD(SerializedAttribute, getType), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("SerializedAttribute", "aabbox3df    getAabbox3df()",
                                     asMETHOD(SerializedAttribute, getAabbox3df), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "aabbox3di    getAabbox3di()",
                                     asMETHOD(SerializedAttribute, getAabbox3di), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "bool         getBool()",
                                     asMETHOD(SerializedAttribute, getBool), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "SColor       getColor()",
                                     asMETHOD(SerializedAttribute, getColor), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "dimension2df getDimension2df()",
                                     asMETHOD(SerializedAttribute, getDimension2df), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "dimension2di getDimension2di()",
                                     asMETHOD(SerializedAttribute, getDimension2di), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "f32          getFloat()",
                                     asMETHOD(SerializedAttribute, getFloat), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "s32          getInt()",
                                     asMETHOD(SerializedAttribute, getInt), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "line2df      getLine2df()",
                                     asMETHOD(SerializedAttribute, getLine2df), asCALL_THISCALL); assert(r >= 0);
	r = engine->RegisterObjectMethod("SerializedAttribute", "line2di      getLine2di()",
	                                 asMETHOD(SerializedAttribute, getLine2di), asCALL_THISCALL); assert(r >= 0);
	r = engine->RegisterObjectMethod("SerializedAttribute", "line3df      getLine3df()",
	                                 asMETHOD(SerializedAttribute, getLine3df), asCALL_THISCALL); assert(r >= 0);
	r = engine->RegisterObjectMethod("SerializedAttribute", "line3di      getLine3di()",
	                                 asMETHOD(SerializedAttribute, getLine3di), asCALL_THISCALL); assert(r >= 0);
	r = engine->RegisterObjectMethod("SerializedAttribute", "Serializable@ getObject()",
	                                 asMETHOD(SerializedAttribute, getObject), asCALL_THISCALL); assert(r >= 0);
	r = engine->RegisterObjectMethod("SerializedAttribute", "recti        getRect()",
	                                 asMETHOD(SerializedAttribute, getRect), asCALL_THISCALL); assert(r >= 0);
	r = engine->RegisterObjectMethod("SerializedAttribute", "string       getString()",
	                                 asMETHOD(SerializedAttribute, getString), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "vector2df    getVector2df()",
                                     asMETHOD(SerializedAttribute, getVector2df), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "vector2di    getVector2di()",
                                     asMETHOD(SerializedAttribute, getVector2di), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "vector3df    getVector3df()",
                                     asMETHOD(SerializedAttribute, getVector3df), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "vector3di    getVector3di()",
                                     asMETHOD(SerializedAttribute, getVector3di), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("SerializedAttribute", "void setAabbox3df(const aabbox3df &in)",
                                     asMETHOD(SerializedAttribute, setAabbox3df), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "void setAabbox3di(const aabbox3di &in)",
                                     asMETHOD(SerializedAttribute, setAabbox3di), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "void setBool(bool)",
                                     asMETHOD(SerializedAttribute, setBool), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "void setColor(const SColor &in)",
                                     asMETHOD(SerializedAttribute, setColor), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "void setDimension2df(const dimension2df &in)",
                                     asMETHOD(SerializedAttribute, setDimension2df), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "void setDimension2di(const dimension2di &in)",
                                     asMETHOD(SerializedAttribute, setDimension2di), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "void setFloat(f32)",
                                     asMETHOD(SerializedAttribute, setFloat), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "void setInt(s32)",
                                     asMETHOD(SerializedAttribute, setInt), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "void setLine2df(const line2df &in)",
                                     asMETHOD(SerializedAttribute, setLine2df), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "void setLine2di(const line2di &in)",
                                     asMETHOD(SerializedAttribute, setLine2di), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "void setLine3df(const line3df &in)",
                                     asMETHOD(SerializedAttribute, setLine3df), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "void setLine3di(const line3di &in)",
                                     asMETHOD(SerializedAttribute, setLine3di), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "void setObject(Serializable@+) ",
                                     asMETHOD(SerializedAttribute, setObject), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "void setObject(ISerializable@+)",
                                     asFUNCTION(setObject), asCALL_CDECL_OBJLAST); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "void setRect(const recti &in)",
                                     asMETHOD(SerializedAttribute, setRect), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "void setString(const string &in)",
                                     asMETHOD(SerializedAttribute, setString), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "void setVector2df(const vector2df &in)",
                                     asMETHOD(SerializedAttribute, setVector2df), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "void setVector2di(const vector2di &in)",
                                     asMETHOD(SerializedAttribute, setVector2di), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "void setVector3df(const vector3df &in)",
                                     asMETHOD(SerializedAttribute, setVector3df), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttribute", "void setVector3di(const vector3di &in)",
                                     asMETHOD(SerializedAttribute, setVector3di), asCALL_THISCALL); assert(r >= 0);
}

#endif // __COMPILE_WITH_ANGELSCRIPT__

// End of File

